package com.guigu.www.controller;


import com.guigu.www.pojo.*;
import com.guigu.www.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 套餐检查分组关联表 前端控制器
 * </p>
 *
 * @author wangyuhao
 * @since 2021-06-19
 */
@RestController
@CrossOrigin
public class TSetmealCheckgroupController {
    @Autowired
    private TSetmealService setmealService;
    @Autowired
    private TSetmealCheckgroupService setmealCheckgroupService;
    @Autowired
    private TCheckgroupService service;
    @Autowired
    private TCheckgroupCheckitemService tCheckgroupCheckitemService;
    @Autowired
    private TCheckitemService tCheckitemService;
    @PostMapping("yy")
    public TYuyshow yuy(@RequestBody TSetmeal tSetmeal){
        TYuyshow tYuyshow=new TYuyshow();
        TSetmeal tSetmeal1 = setmealService.selectById(tSetmeal.getSid());
        List<TSetmealCheckgroup> tsetmealshow = setmealCheckgroupService.tsetmealshow(tSetmeal.getSid());
        List<TCheckgroup> list1=new ArrayList();
        for (TSetmealCheckgroup x:
                tsetmealshow) {
            TCheckgroup tCheckgroup = service.selectById(x.getCheckgroupId());
            list1.add(tCheckgroup);
        }
        List<TCheckitem> list2=new ArrayList<>();
        for (TCheckgroup b:
             list1) {
            List<TCheckgroupCheckitem> tCheckgroupCheckitems=tCheckgroupCheckitemService.selectitem(b.getId());
            for (TCheckgroupCheckitem a:
                    tCheckgroupCheckitems) {
                TCheckitem tCheckitem = tCheckitemService.selectById(a.getCheckitemId());
                list2.add(tCheckitem);
            }
        }
        tYuyshow.setTSetmeal(tSetmeal1);
        tYuyshow.setListTCheckgroup(list1);
        tYuyshow.setListTCheckitem(list2);
        return tYuyshow;
    }


}

